<template>
  <div>
    <div class="top_img">
      <img src="../assets/Snipaste_2021-04-21_16-48-14.png" alt="">
      <div class="top_icon">
        <div>
          <i class="iconfont iconjiantou" @click="$router.back()" />
        </div>
        <div>
          <i class="iconfont iconsousuo" />
          <i class="iconfont iconpinglun"><span>关注</span></i>
          <i class="iconfont iconyuanneidingcan" />
        </div>
      </div>
    </div>
    <div class="head_card">
      <div class="head_left">
        <div class="head_name">春记小龙虾面</div>
        <div class="present">峰鸟快送</div>
        <div class="notice">公告：春记小龙虾面愿您新春快乐</div>
        <div class="discounts">
          <div class="discounts_condition">20减4 <span> | </span> 35减8</div>
          <div class="firs">首次光临减4</div>
        </div>
      </div>
      <div class="head_right">
        <div>
          <img src="../assets/Snipaste_2021-04-21_16-48-14.png" alt="">
          <div class="brand" />
        </div>
        <div class="discounts">7个优惠<i class="iconfont iconjiantou" /></div>
      </div>
    </div>

    <div class="tabs">
      <van-tabs v-model="active">
        <van-tab title="点餐" />
        <van-tab title="评价" />
        <van-tab title="商家" />
      </van-tabs>
      <div class="share">好友拼单</div>
    </div>

    <div class="swipe_box">
      <div class="myswipe">
        <myswipe />
      </div>
    </div>
    <div class="menu">
      <div class="menu_classify">
        <div
          v-for="(v, i) in 30"
          :key="i"
          class="classify_name"
          :class="{ add: list === i }"
          @click="classify(i)"
        >
          小吃
        </div>
      </div>
      <div class="menu_commodity">
        <h4>刚刚看过</h4>
        <div v-for="(v, i) in shu" :key="i" class="classify_name">
          <myshop :islist="false" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import myswipe from '@/components/swipe'
import myshop from '@/components/shop'

import { getName } from '@/api/user'
export default {
  components: {
    myswipe,
    myshop
  },
  data() {
    return {
      active: 0,
      list: 0,
      shu: 30
    }
  },

  mounted() {
    this.classify(0)
    this.getName()
  },
  methods: {
    classify(i) {
      this.list = i
      this.shu = this.shu === 30 ? 20 : 30
    },
    async getName() {
      const res = await getName(1)
      console.log(res)
    }
  }
}
</script>

<style lang="scss" scoped>
.top_img {
  position: relative;
  z-index: -1;
  img {
    width: 100%;
    height: 160px;
  }
  .top_icon {
    width: 100%;
    position: absolute;
    top: 50px;
    display: flex;
    justify-content: space-between;
    .iconfont {
      font-size: 24px;
      color: #fff;
      margin-right: 20px;
      span {
        font-size: 16px;
      }
    }
    .iconjiantou {
      margin-left: 20px;
    }
  }
}

.head_card {
  padding: 15px;
  width: 94vw;
  margin-left: 3vw;
  height: 145px;
  margin-top: -70px;
  background-color: #fff;
  border-radius: 10px;
  border-left: 1px solid #0000000a;
  border-right: 1px solid #0000000a;
  display: flex;
  justify-content: space-between;
  .discounts {
    display: flex;
    margin-top: 10px;
    .discounts_condition,
    .firs {
      padding: 3px;
      border: 1px solid #ccc;
      font-size: 12px;
      color: #d0877b;
      margin-right: 5px;
      border-radius: 5px;
      span {
        color: #ccc;
        line-height: 16px;
      }
    }
  }
  .head_name {
    font-size: 18px;
    font-weight: 700;
  }
  .present {
    font-size: 12px;
    color: #4e4e4e;
    margin-top: 20px;
    margin-bottom: 10px;
  }
  .notice {
    font-size: 12px;
    color: #a6a6a6;
    margin-bottom: 20px;
  }
  .head_right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    img {
      width: 70px;
      height: 70px;
      border-radius: 10px;
    }
    .discounts {
      color: #aeaeae;
      font-size: 12px;
    }
  }
}

.tabs {
  display: flex;
  padding: 0 15px;
  position: sticky;
  top: 0px;
  justify-content: space-between;
  align-items: center;
  z-index: 99;
  background-color: #fff;
  .share {
    padding: 5px;
    font-size: 12px;
    height: 30px;
    line-height: 18px;
    border: 1px solid #ccc;
    border-radius: 15px;
    color: #81bcca;
  }
}

.swipe_box {
  width: 100%;
  padding: 0 15px;
  margin-top: 20px;
  height: 140px;
  .myswipe {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ccc;
  }
}

.menu {
  margin-top: 30px;
  display: flex;
  font-size: 12px;
  .menu_classify {
    flex: 1;
    height: 800px;
    background-color: #ce1010;
    overflow-y: scroll;

    .classify_name {
      width: 100%;
      height: 50px;
      line-height: 50px;
      background-color: #f2f2f2;
      text-align: center;
    }
    .add {
      background-color: #fff;
      font-weight: 700;
    }
  }
  .menu_commodity {
    flex: 4;
    height: 800px;
    overflow-y: scroll;
    h4 {
      position: sticky;
      top: 0px;
      background-color: #fff;
      height: 30px;
      padding-left: 10px;
      line-height: 30px;
      font-weight: 600;
      font-size: 14px;
    }
    .classify_name {
      width: 100%;
      height: 160px;
      background-color: #16eb99;
    }
  }
}
</style>
